package com.koron.order.common.bean.base;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @ClassName ButtonUserType
 * @description 按钮-操作用户类型
 * @Author zhouj
 * @Date 2022/3/22 8:31
 */
public class ButtonUserType {

    public static Map<String, List<String>> init(ButtonCode buttonCode, JurisdictionUserType... jurisdictionUserTypes) {

        return new HashMap<String, List<String>>() {{
            List<JurisdictionUserType> userTypes = Arrays.asList(jurisdictionUserTypes);
            List<String> userTypeList = userTypes.stream().map(JurisdictionUserType::getCode).collect(Collectors.toList());
            put(buttonCode.getCode(), userTypeList);
        }};
    }

    public static void put(Map<String, List<String>> cond, ButtonCode buttonCode, JurisdictionUserType... jurisdictionUserTypes) {
        List<JurisdictionUserType> userTypes = Arrays.asList(jurisdictionUserTypes);
        List<String> userTypeList = userTypes.stream().map(JurisdictionUserType::getCode).collect(Collectors.toList());
        cond.put(buttonCode.getCode(), userTypeList);
    }

}
